package com.gonsin.base.exceptions;

import lombok.Getter;

/**
 * 请求失败统一报此异常
 */
public class MyException extends RuntimeException {

    private int status;         // 错误码

    private String message;     // 错误时显示的内容

    private Object[] args;

    public MyException(int state, String message, Object ... args) {
        super(message);
        this.status = state;
        this.message = message;
        this.args = args;
    }

    public MyException(int state, String message) {
        super(message);
        this.status = state;
        this.message = message;
        this.args = null;
    }

    public MyException(IResultCode result) {
        super(result.getName());
        this.status = result.getValue();
        this.message = result.getName();
    }

    public MyException(IResultCode result, String message) {
        super(result.getName());
        this.status = result.getValue();
        this.message = message;
        this.args = null;
    }

    public MyException(IResultCode result, String message, Object ... args) {
        super(result.getName());
        this.status = result.getValue();
        this.message = message;
        this.args = args;
    }

    @Override
    public String getMessage(){
        return this.message;
    }


    public int getStatus(){
        return status;
    }


    public Object[] getArgs(){
        return args;
    }


    //    public MyException(String message, Throwable cause) {
//        super(message, cause);
//    }
//
//    public MyException(Throwable cause) {
//        super(cause);
//    }
//
//    public MyException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {
//        super(message, cause, enableSuppression, writableStackTrace);
//    }

}
